package com.luculent.util.extension.validator.constraintvalidation;

import cn.hutool.core.lang.Validator;
import com.luculent.util.extension.validator.constraints.Mobile;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 
 *验证手机号
 *@author: zhangyang
 *@since: 2019年1月31日下午4:19:58
 */
public class MobileValidator implements ConstraintValidator<Mobile, String> {


    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(StringUtils.isEmpty(value)) {
        	return true;
        }
        return Validator.isMobile(value);
    }

	@Override
	public void initialize(Mobile constraintAnnotation) {
		// TODO Auto-generated method stub
		
	}
}